package 数学编码器;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 10010, MOD = (int) (1e9 + 7);
    static int[] a = new int[N];
    static int[] p = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        p[0] = 1;
        for (int i = 1; i < N; i++) {
            p[i] = (p[i - 1] << 1) % MOD;
        }
        for (int cases = 1; cases <= T; cases++) {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a, 0, n);
            long res = 0;
            for (int i = 0; i < n; i++) {
                res = ((res + (long) a[i] * (p[i] - p[n - i - 1])) % MOD);
            }
            System.out.printf("Case #%d: %d\n", cases, res);
        }
    }
}
